//
//  SNKNewsTableCell.m
//  SleepNews
//
//  Created by Kavee DJ on 2016/12/11.
//  Copyright © 2016年 Kavee DJ. All rights reserved.
//

#import "SNKNewsTableCell.h"
#import "SNKNewsModel.h"

#import <UIImageView+WebCache.h>
#import <NSDate+DateTools.h>

@interface SNKNewsTableCell ()

@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
@property (weak, nonatomic) IBOutlet UILabel *labelTime;
@property (weak, nonatomic) IBOutlet UIImageView *imageViewPicture;


@end

@implementation SNKNewsTableCell

- (void)setNews:(SNKNewsModel *)news {
    _news = news;
    
    self.labelTitle.text = news.title;
    [self.imageViewPicture sd_setImageWithURL:[NSURL URLWithString:news.pic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    
    // 处理时间
    NSString *ptimeString = news.time;
    NSString *fmt = @"YYYY/MM/dd HH:mm";
    NSDate *timeAgoDate = [NSDate dateWithString:ptimeString formatString:fmt];
    self.labelTime.text = timeAgoDate.timeAgoSinceNow;
}

- (void)setFrame:(CGRect)frame {
    
    frame.size.height -= 1;
    [super setFrame:frame];
}

@end
